﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Entities;

namespace WebApp
{
    public class CommandModelView 
    {
        //
        // GET: /CommandModelView/
        public Commande commande { get; set; }
        public List<Plat> All_Plats { get; set; }

        public List<Plat> Entrees
        {
            get { return this.getListPlatByType(TypePlat.Entrée); }
        }

        public List<Plat> Plat
        {
            get { return this.getListPlatByType(TypePlat.PlatPrincipal); }
        }
        public List<Plat> Dessert
        {
            get { return this.getListPlatByType(TypePlat.Dessert); }
        }
        public List<Plat> Boisson
        {
            get { return this.getListPlatByType(TypePlat.Boisson); }

        }
        public List<Plat> Formule
        {
            get { return this.getListPlatByType(TypePlat.Autres); }

        }

        public CommandModelView(List<Plat> plats){
            this.All_Plats = plats;
            /*this.Entrees = this.getListPlatByType(TypePlat.Entrée);
            this.Plat = this.getListPlatByType(TypePlat.PlatPrincipal);            
            this.Dessert = this.getListPlatByType(TypePlat.Dessert);
            this.Boisson = this.getListPlatByType(TypePlat.Boisson);
            this.Formule = this.getListPlatByType(TypePlat.Autres);*/
        }
        private List<Plat> getListPlatByType(TypePlat type)
        {
            List<Plat> mylist = new List<Plat>();
            foreach(Plat item in All_Plats){
                Plat myplat = item;
                if(item.getType().Equals(type))
                    mylist.Add(item);
            }
            return mylist;
        }
    }
}
